<?php

/**
 * 基础控制器
 */

namespace app\member\controller;


class LoginController extends \app\member\common\LoginCommon {


    public function index() {
        parent::index();
    }

    public function bind() {
        parent::bind();
    }

    public function logout() {
        parent::logout();
    }

    public function status() {
        $action = request('', 'action');
        $action = str_replace(DOMAIN, '', $action);
        if(strpos($action, '/', 0) === false) {
            $action = '';
        }

        $msg = '您好,欢迎您的到来 <a href="'.url('member/login/index', ['action' => $action]).'">[登录]</a> <a href="'.url('member/register/index').'">[注册]</a>';
        $login = \Dux::cookie()->get('user_login');
        if(empty($login)) {
            $this->error($msg);
        }
        if(!target('member/Member', 'service')->checkUser($login['uid'], $login['token'])) {
            $this->error($msg);
        }
        $userInfo = target('member/Member', 'service')->getUser($login['uid']);
        if(!$userInfo) {
            $this->error($msg);
        }else {
            $this->success('您好,欢迎您再次回来<a href="'.url('member/Index/index').'">'.$userInfo['nickname'] .'</a> <a href="'.url('member/login/logout').'">[退出]</a>');
        }
    }

}